<!-- @Author: Yu_Bo -->
<template>
	<view class="details">
		<!-- 书 -->
		<view class="details_list">
			<view class="list" v-for="(item,index) in goods_order" :key="index">
				<view class="img">
					<image :src="item.image" mode="aspectFill"></image>
				</view>
				<view class="info">
					<view class="title line_one">
						{{item.goods_name}}
					</view>
					<view class="txt line_one">
						{{item.author}}/{{item.press}}
					</view>
					<view class="tip line_one">
						{{item.label}}
					</view>
					<view class="sku">
						{{item.condition==1?'新书':'二手'}}
					</view>
					<view class="money">
						<view class="left">
							<text class="icon">￥</text>
							<text class="num">{{item.goods_price}}</text>
							<text class="zhe color1" v-if="item.condition==0">二手{{item.discount}}折</text>
							<text class="zhe color2" v-if="item.condition==1">新书{{item.discount}}折</text>
						</view>
						<view class="right">
							x{{item.total_num}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 总价 -->
		<view class="details_box">
			<view class="left">
				总价
			</view>
			<view class="right1">
				￥{{total_price}}
			</view>
		</view>
		<!-- 运费 -->
		<view class="details_box">
			<view class="left">
				运费
			</view>
			<view class="right1">
				￥{{express_price}}
			</view>
		</view>
		<!-- 订单编号 -->
		<view class="details_box">
			<view class="left">
				订单编号
			</view>
			<view class="right">
				{{order_no}}
			</view>
		</view>
		<!-- 快递单号 -->
		<view class="details_box" v-if="express_no">
			<view class="left">
				快递单号
			</view>
			<view class="right">
				<text @click="copyBtn">复制</text>
				{{express_no}}
			</view>
		</view>
		<!-- 收货人 -->
		<view class="details_box">
			<view class="left">
				收货人
			</view>
			<view class="right">
				{{name}}
			</view>
		</view>
		<!-- 联系电话 -->
		<view class="details_box">
			<view class="left">
				联系电话
			</view>
			<view class="right">
				{{phone}}
			</view>
		</view>
		<!-- 收货地址 -->
		<view class="details_txt">
			<view class="left">
				收货地址
			</view>
			<view class="right">
				{{location}}
			</view>
		</view>
		<!-- 备注 -->
		<view class="details_txt">
			<view class="left">
				备注
			</view>
			<view class="right">
				{{remarks || "--"}}
			</view>
		</view>
		<!-- 底部按钮 -->
		<c-footer v-if="status==2">
			<view class="footer_btn_two" v-if="express_no">
				<view class="btn_txt_left" @click="copyBtn">
					复制快递单号
				</view>
				<view class="btn_txt color_right page_button" @click="shouBtn">
					确认收货
				</view>
			</view>
			<view class="footer_btn" v-else>
				<view class="btn_txt color_right page_button" @click="shouBtn">
					确认收货
				</view>
			</view>
		</c-footer>
		<!--  -->
		<c-prompttwo ref="promptshou" text="确认收到货了吗?" @confirm="confirmShou"></c-prompttwo>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return{
				id: "",
				goods_order: [],
				total_price: "",
				express_price: "",
				order_no: "",
				express_no: "",
				name: "",
				phone: "",
				location: "",
				remarks: "",
				status: null,
				btnLoading: false
			}
		},
		computed: {},
		onLoad(opt) {
			if(opt.id) {
				this.id = opt.id
				this.getDetails()
			}
		},
		onShow() {},
		methods: {
			// 获取详情
			getDetails() {
				var that = this
				var params = {
					order_id: that.id
				}
				that.$httpApi.expressorderDetail(params).then((res) => {
					if (res.code == 1) {
						that.goods_order = res.data.goods_order
						that.total_price = res.data.total_price
						that.express_price = res.data.express_price
						that.order_no = res.data.order_no
						that.express_no = res.data.express_no
						that.name = res.data.name
						that.phone = res.data.phone
						that.location = res.data.location
						that.remarks = res.data.remarks
						that.status = res.data.status
					}
				})
			},
			// 确认收货
			shouBtn() {
				this.$refs.promptshou.openBtn()
			},
			confirmShou() {
				var that = this
				if(that.btnLoading) return
				that.btnLoading = true
				var params = {
					order_id: that.id,
				}
				that.$httpApi.confirm(params).then((res) => {
					that.btnLoading = false
					if (res.code == 1) {
						that.status = 4
						that.$forceUpdate()
					}
				})
			},
			// 复制
			copyBtn(val) {
				uni.setClipboardData({
					data: this.express_no,
					success: function () {
						console.log('success');
					}
				});
			},
		},
	}
</script>

<style lang='scss' scoped>
	.details {
		width: 100%;
		min-height: 100vh;
		padding: 30rpx;
		background: #f6f6f6;
		
		.details_list {
			width: 100%;
			
			.list {
				width: 100%;
				padding: 20rpx;
				margin-bottom: 30rpx;
				background: #fff;
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				
				.img {
					width: 180rpx;
					height: 240rpx;
					
					image {
						display: block;
						width: 100%;
						height: 100%;
					}
				}
				
				.info {
					width: calc(100% - 180rpx);
					height: 240rpx;
					padding-left: 20rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					
					.title {
						width: 100%;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 32rpx;
						color: #222222;
					}
					
					.txt {
						width: 100%;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #666666;
					}
					
					.tip {
						width: 100%;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #00A8FF;
					}
					
					.sku {
						width: 100%;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #222222;
					}
					
					.money {
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: space-between;
						
						.left {
							display: flex;
							align-items: center;
							
							.icon {
								padding-top: 5rpx;
								font-family: PingFang SC, PingFang SC;
								font-weight: bold;
								font-size: 24rpx;
								color: #5A68FF;
							}
							
							.num {
								font-family: PingFang SC, PingFang SC;
								font-weight: bold;
								font-size: 36rpx;
								color: #5A68FF;
							}
							
							.zhe {
								margin-left: 30rpx;
								padding: 2rpx 10rpx;
								font-family: PingFang SC, PingFang SC;
								font-weight: 400;
								font-size: 22rpx;
								background: #fff;
								border-radius: 10rpx;
							}
							
							.color1 {
								color: #57CB82;
								border: 2rpx solid #57CB82;
							}
							
							.color2 {
								color: #FF9400;
								border: 2rpx solid #FF9400;
							}
						}
						
						.right {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 28rpx;
							color: #666666;
						}
					}
				}
			}
			
			.list:last-child {
				margin-bottom: 0;
			}
		}
		
		.details_box {
			width: 100%;
			margin-top: 30rpx;
			padding: 30rpx;
			background: #ffffff;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			
			.left {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #666666;
			}
			
			.right {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #222222;
				display: flex;
				align-items: center;
				
				text {
					margin-right: 30rpx;
					color: #5A68FF;
				}
			}
			
			.right1 {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #FF3E3E;
			}
		}
		
		.details_txt {
			width: 100%;
			margin-top: 30rpx;
			padding: 30rpx;
			background: #ffffff;
			border-radius: 20rpx;
			display: flex;
			justify-content: space-between;
			
			.left {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #666666;
			}
			
			.right {
				width: 450rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #222222;
				text-align: right;
			}
		}
		
		.footer_btn {
			width: 100%;
			padding: 30rpx 30rpx;
			background: #fff;
			
			.btn_txt {
				width: 100%;
				height: 90rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #FFFFFF;
				border-radius: 45rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
		
		.footer_btn_two {
			width: 100%;
			padding: 30rpx 30rpx;
			background: #fff;
			display: flex;
			justify-content: space-between;
			
			.btn_txt_left {
				width: 330rpx;
				height: 90rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #999999;
				border-radius: 45rpx;
				border: 2rpx solid #999999;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			
			.btn_txt {
				width: 330rpx;
				height: 90rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #FFFFFF;
				border-radius: 45rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}
</style>